<template>
  <div>这是子组件</div>
  <button @click="getParentFun">改变子类数据</button>

</template>
<script setup lang="ts">
import { defineComponent, ref } from 'vue';
const childData = ref("子类数据：")
const emit = defineEmits(['on-ChildClick'])
const getParentFun = () => {
  console.log("子类点击事件");
  emit('on-ChildClick', "子组件发送")
}
const childClick = () => {
  console.log(`触发子类方法：${childData.value}`)
  childData.value = childData.value + "1"
}
//暴露数据
defineExpose({
  childData, childClick
})

// defineEmits({

// })
// defineProps({

// })
</script>

<!-- <script lang="ts">
import { defineComponent, ref } from 'vue';

export default defineComponent({
  emits: [
    'child-click'
  ],
  props: {
    msg: String
  },
  setup(props, context) {
    const getParentFun = () => {
      context.emit('child-click', context)
    }
    const childFun = () => {
      console.log("子组件方法触发")
    }
    return {
      props, getParentFun, childFun
    }
  }
})

</script> -->